<?php
require_once PATH_SITE.'cn/royan/php/utils/builders/BuilderEvent.builder.php';
require_once PATH_SITE.'cn/royan/php/parses/SimpleParse.class.php';
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of ValidLoginParse
 *
 * @author yanr
 */
class ValidLoginParse extends SimpleParse
{
    const TYPE          = "ValidLogin";
    const ERROR_10001   = "error_10001";//has logout
    //put your code here
    static public function getInstance()
    {
        IF( is_null( self::$instance ) ) self::$instance = new ValidLoginParse( ValidLoginParse::TYPE );
        RETURN self::$instance;
    }
    
    public function __construct($typeName = NULL) {
        parent::__construct($typeName);
    }
    
    protected function isValid($info) {
        IF ( parent::isValid($info) === FALSE ) RETURN FALSE;
        
        IF ( $info["user"]->__get("isLogin") !== TRUE )
        {
            $data = array( "event"=>    BuilderEvent::ERROR,
                           "code"=>     ValidLoginParse::ERROR_10001,
                           "target"=>   ValidLoginParse::TYPE,
                           "user"=>     $info["user"]); 
            
            $this->sendNotification( ApplicationFacade::DISPATCH_EVENT, $data );
            RETURN FALSE;
        }
        RETURN TRUE;
    }
}

?>
